<?php $auth=0; ?>
<?php include 'lib/includes.php'; ?>
<?php include 'partials/header_menu.php'; ?>
<?php
$nom='';$prenom='';$portable='';$mail='';$carte='';$dateEx='';
if(isset($_POST['nom'])&&isset($_POST['prenom'])&&isset($_POST['portable'])&&isset($_POST['mail'])&&isset($_POST['carte'])&&isset($_POST['dateEx'])) 
{
        
		$nom=$db->quote($_POST['nom']);
		$prenom=$db->quote($_POST['prenom']);
		$portable=$db->quote($_POST['portable']);
		$mail=$db->quote($_POST['mail']);
		$carte=$db->quote($_POST['carte']);
		$dateEx=$db->quote($_POST['dateEx']);
		if(isset($_GET['id'])){
		$id=$db->quote($_GET['id']);
		$db->query("update client set clientNom=$nom,clientPrenom=$prenom,clientPhone=$portable,clientMail=$mail,creditcard=$carte,clientCredidate=$dateEx where clientId=$id");
		header('Location: /prescription/user.php');
		die();
		}else
		{
		$db->query("insert into client set clientNom=$nom,clientPrenom=$prenom,clientPhone=$portable,clientMail=$mail,creditcard=$carte,clientCredidate=$dateEx");
		header('Location: /prescription/user.php');
		die();
		}
}

if(isset($_GET['id'])){
	
		$id=$db->quote($_GET['id']);
		$select=$db->query("select * from client where clientId=$id");
	    $_POST=$select->fetch();
		$nom=$db->quote($_POST['clientNom']);
		$prenom=$db->quote($_POST['clientPrenom']);
		$portable=$db->quote($_POST['clientPhone']);
		$mail=$db->quote($_POST['clientMail']);
		$carte=$db->quote($_POST['creditcard']);
		$dateEx=$db->quote($_POST['clientCredidate']);
		
	}
	
?>
<form class="form-horizontal"  method="post">
<br>
<h3><span class="titre">&nbsp;Profil du client</span></h3>
<br>
   <div class="form-group">
    <label for="inputPassword3" class="col-sm-4 control-label">Nom :</label>
    <div class="col-sm-5">
     <input type="text" class="form-control"  name="nom" value="<?php echo str_replace("'","",$nom) ; ?>">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-4 control-label">Prénom :</label>
    <div class="col-sm-5">
     <input type="text" class="form-control"  name="prenom" value="<?php echo str_replace("'","",$prenom) ; ?>">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-4 control-label">Portable :</label>
    <div class="col-sm-5">
     <input type="text" class="form-control"  name="portable" value="<?php echo str_replace("'","",$portable) ; ?>">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-4 control-label">Mail :</label>
    <div class="col-sm-5">
     <input type="text" class="form-control"  name="mail" value="<?php echo str_replace("'","",$mail) ; ?>">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-4 control-label">Carte de crédit :</label>
    <div class="col-sm-5">
     <input type="text" class="form-control"  name=" carte" value="<?php echo str_replace("'","",$carte) ; ?>">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-4 control-label">Date d'expiration :</label>
    <div class="col-sm-5">
     <input type="text" class="form-control"  name="dateEx" value="<?php echo str_replace("'","",$dateEx) ; ?>">
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-4 col-sm-10">
      <button type="submit" class="btn btn-success">valider</button>
	  <a href="user.php" class="btn btn-default">annuler</a>
    </div>
  </div>
</form>
<?php include 'partials/footer.php'; ?>
